package com.idanchuang.support.etcache.remote.redis;

import com.idanchuang.support.etcache.remote.RemoteCache;
import com.idanchuang.support.etcache.remote.RemoteCacheConfig;
import com.idanchuang.support.etcache.remote.RemoteCacheFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;

/**
 * 远程缓存对象工厂 Redis 实现
 *
 * @author yjy
 * Created at 2021/12/23 8:46 下午
 */
public class RedisRemoteCacheFactory implements RemoteCacheFactory {

    private final RedisConnectionFactory connectionFactory;

    public RedisRemoteCacheFactory(RedisConnectionFactory connectionFactory) {
        this.connectionFactory = connectionFactory;
    }

    @Override
    public <K, V> RemoteCache<K, V> getBean(RemoteCacheConfig config) {
        return new SpringRedisEtCache<>(config, connectionFactory);
    }

}
